package com.open.capacity.paper.controller;

import com.open.capacity.common.model.RateOption;
import com.open.capacity.common.web.Result;
import com.open.capacity.paper.service.RateOptionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/rateOption")
@Api(tags = "评分选项")
public class RateOptionController {
    @Autowired
    RateOptionService rateOptionService;
    @GetMapping("/getRateOptionList")
    @ApiOperation("获取所有评分类型")
    public Result getRateOptionList(){
        return Result.succeed(rateOptionService.getRateOptionList(),"success");
    }
    @GetMapping("/getRateOption")
    @ApiOperation("根据id获取评分类型")
    public Result getRateOption(Integer rtopid){
        return Result.succeed(rateOptionService.getRateOption(rtopid),"success");
    }
    @PostMapping("/addRateOption")
    @ApiOperation("添加评分类型")
    public Result addRateOption(@RequestBody RateOption rateOption){
        if (rateOptionService.addRateOption(rateOption)>0){
            return Result.succeed("添加成功");
        }
        return Result.failed("添加失败");
    }
    @PostMapping("/updateRateOption")
    @ApiOperation("修改评分类型")
    public Result updateRateOption(@RequestBody RateOption rateOption){
        if (rateOptionService.updateRateOption(rateOption)>0){
            return Result.succeed("修改成功");
        }
        return Result.failed("修改失败");
    }
    @GetMapping("/deleteRateOption")
    @ApiOperation("删除评分类型")
    public Result deleteRateOption(Integer rtopid){
        if (rateOptionService.deleteRateOption(rtopid)>0){
            return Result.succeed("删除成功");
        }
        return Result.failed("删除失败");
    }
}
